﻿using ERP.Common.Results;
using ERP.Team.RBAC.xzc;
using ERP.UserLogin.IService;
using Microsoft.AspNetCore.Mvc;
using ERP.Team.RBAC.xzc;

using System.Threading.Tasks;

namespace ERP.Web.Controllers.wyx.Login
{
    /// <summary>
    /// 登陆视图
    /// </summary>
    public class MVCLoginController : Controller
    {
        /// <summary>
        /// 登陆接口
        /// </summary>
        private readonly ILoginService _loginService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="loginService">登陆接口</param>
        public MVCLoginController(ILoginService loginService)
        {
            _loginService = loginService;
        }

        /// <summary>
        /// 登陆
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult LoginIndex()
        {
            return View();
        }

        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>返回任务</returns> 
        [HttpGet]
        public async Task<APIResult<UserModel>> LoginQuery(string username, string password)
        {
            return await _loginService.LoginQuery(username, password);
        }
    }
}
